<?php

namespace Cktadmin\Controller;

use Common\Controller\BasicAdmin;
use Common\Service\DataService;

class BuyController extends BasicAdmin {

    public $table = 'order';

    public function index() {
        $this->title = '购买记录';
        $get = I('get.');
        $where = array('is_deleted' => 1);
        (isset($get['key']) && $get['key'] !== '') && $where['courier_num|state|category|source'] = array('like', "%{$get['key']}%");
        $count = M($this->table)->where($where)->count();
        $db = M($this->table)->where($where)->order('add_time desc');
        return parent::_list($db, $count);
    }

    public function del() {
        if (DataService::update($this->table)) {
            $this->success('删除成功！');
        }
        $this->error('删除失败！');
    }

}
